package com.fanh.controller;

import com.fanh.common.api.CommonResult;
import com.fanh.model.GuideFeedback;
import com.fanh.service.GuideFeedbackService;
import com.fanh.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@Api(tags = "SetingController", description = "个人设置")
@RequestMapping("/")
public class SetingController {


    @Autowired
    private GuideFeedbackService guideFeedbackService;
    @Autowired
    private UserService userService;

    @ApiOperation("意见反馈")
    @RequestMapping(value = "a/guide/s/feedback", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult feedback(@RequestBody GuideFeedback guideFeedback) {

        guideFeedback.setUserId(userService.getCurrentSysUser().getId());
       int count = guideFeedbackService.add(guideFeedback);
       if(count >0 ){
          return  CommonResult.success(count);
       }
        return  CommonResult.failed("反馈失败");
    }



    @ApiOperation("检查版本更新")
    @RequestMapping(value = "guide/checkVersion", method = RequestMethod.GET)
    @ResponseBody
    public CommonResult checkVersion(@ApiParam(value = "版本号",required = true)@RequestParam("version") String version) {
        if ("0.0".equals(version)) {
            return CommonResult.success("1");
        } else {
            return CommonResult.success("0");
        }
    }

}
